﻿using IterationLife.Educations.Models;
using Util;
using Util.Maps;

namespace IterationLife.PlatformBackEnd.AppServices.Dtos.Educations {
    /// <summary>
    /// 教材版本数据传输对象扩展
    /// </summary>
    public static class TextbookEditionDtoExtension {
        /// <summary>
        /// 转换为教材版本实体
        /// </summary>
        /// <param name="dto">教材版本数据传输对象</param>
        public static TextbookEdition ToEntity( this TextbookEditionDto dto ) {
            if ( dto == null )
                return new TextbookEdition();
            return dto.MapTo( new TextbookEdition( dto.Id.ToGuid() ) );
        }
        
        /// <summary>
        /// 转换为教材版本数据传输对象
        /// </summary>
        /// <param name="entity">教材版本实体</param>
        public static TextbookEditionDto ToDto(this TextbookEdition entity) {
            if( entity == null )
                return new TextbookEditionDto();
            return entity.MapTo(new TextbookEditionDto());
        }
    }
}
